//
//  TYHSubFuctionView.m
//  OpenPractice
//
//  Created by tanyuehong on 15/1/19.
//  Copyright © 2019年  lijinghua. All rights reserved.
//

#import "OPHomeGusLikeView.h"
#import "OPHomeContentCell.h"

@interface OPHomeGusLikeView ()

@property (nonatomic,strong) UIView *gustView;

@end

@implementation OPHomeGusLikeView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self initGussYouLike];
        [self layoutMySubview];
        [self updateGusLikeData:@[@(OPHomeContentCellClass),@(OPHomeContentCellClass),@(OPHomeContentCellClass)]];
        self.backgroundColor = kOPBackgroundColor;
    }
    return  self;
}


- (void)layoutMySubview {
}


- (void)updateGusLikeData:(NSArray *)clsData {
    for (NSInteger i=0; i<clsData.count; i++) {
        OPHomeContentCell *myCell = [[OPHomeContentCell alloc] initWithContentData:clsData[i]];
        [self addSubview:myCell];
        [myCell mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(35 + i*120));
            make.width.equalTo(self);
            make.left.equalTo(self);
            make.height.equalTo(@120);
        }];
    }
}

- (void)initGussYouLike {
    UIView *bigSprate = [[UIView alloc] init];
    bigSprate.backgroundColor = kOPSeparateBackgroundColor;
    [self addSubview:bigSprate];
    [bigSprate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.top.equalTo(self);
        make.height.equalTo(@20);
    }];
    
    UILabel *tilteLable = [[UILabel alloc] init];
    tilteLable.text = @"猜你喜欢";
    tilteLable.font = [UIFont systemFontOfSize:12];
    tilteLable.textColor = kTYH333333TextColor;
    [tilteLable sizeToFit];
    tilteLable.center = CGPointMake(self.width/2, (self.height-20)+tilteLable.height/2);
    [self addSubview:tilteLable];
    UIView *sprateView1 = [[UIView alloc] initWithFrame:CGRectMake(tilteLable.left-13, tilteLable.centerY-0.5, 10, 1 )];
    sprateView1.backgroundColor = kSingleLineColor;
    UIView *sprateView2 = [[UIView alloc] initWithFrame:CGRectMake(tilteLable.right+3,tilteLable.centerY-0.5, 10, 1)];
    sprateView2.backgroundColor = kSingleLineColor;
    [self addSubview:sprateView1];
    [self addSubview:sprateView2];
    
    [tilteLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self).offset(0);
        make.height.equalTo(@(tilteLable.height));
    }];
    
    [sprateView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(tilteLable.mas_left).offset(-13);
        make.top.equalTo(tilteLable.mas_centerY).offset(-0.5);
        make.height.equalTo(@(1));
        make.width.equalTo(@(10));
    }];
    
    [sprateView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(tilteLable.mas_right).offset(3);
        make.top.equalTo(tilteLable.mas_centerY).offset(-0.5);
        make.height.equalTo(@(1));
        make.width.equalTo(@(10));
    }];
    self.gustView = tilteLable;
}

@end
